# Makefile for utelnetd

# compiler configure
#CROSS_COMPILE := arm-linux-gnueabi-
CC            := $(CROSS_COMPILE)gcc
LOGIN         := /bin/login
CFLAGS	      := -I. -pipe -DSHELLPATH=\"$(LOGIN)\" -Wall
LDFLAGS       ?=
LDLIBS        ?=

# install configure
INSTDIR	  := ./
INSTALL   := install
INSTMODE  = 0755
INSTOWNER = root
INSTGROUP = root

# where to find login program
TARGET   = utelnetd
OBJS     = utelnetd.o

# if use debug
ifneq ("","$(DEBUG)")
CFLAGS   += -DDEBUG -g -Os
STRIP	  = \#
else
CFLAGS	 += -fomit-frame-pointer
STRIP	  = $(CROSS)strip 
endif

# if BSD arch
ifeq ("1", "$(BSD)")
CFLAGS   += -DBSD
endif


all: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
	$(STRIP) --remove-section=.comment --remove-section=.note $@

.PHONY: install
install: $(TARGET)
	$(INSTALL) -d $(INSTDIR)
	$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) $(TARGET) $(INSTDIR)

.PHONY: clean
clean:
	rm -f $(TARGET) *.o
